<?php
/**
 * This is the index.ctp
 * @access public
 * @version 1.0
 */
?>
<!-- Main content -->
<section role="main" id="main">
    <!-- Header -->
    <?php
        echo $this->element('page_header');
        echo $this->element('navigations/admin_navbar');
    ?>

    <div class="with-padding">
        <div class="columns">
            <div class="new-row-mobile twelve-columns six-columns-tablet twelve-columns-mobile">

                <h3 class="thin underline">Groups</h3>

                <table id="groupflex" style="display:none;"></table>

                <div style="display: none;">
                    <div id="group-form-window" style="margin: 20px 5px 5px 5px;">
                        <div class="group-prompt" ></div>

                        <?php echo $this->Form->create('Group', array('default' => false, 'id' => 'group-form', 'action' => 'add','inputDefaults' => array('label' => false,'div' => false)));?>
                        <fieldset class="fieldset">
                            <legend class="legend">Info</legend>

                            <p class="button-height inline-label">
                                <label class="label">Group Name</label>
                                <?php echo $this->Form->input('name', array('id'=>'name', 'class' => 'input validate[required] ', 'value'=>'', 'div' => false, 'label' => false,)); ?>
                            </p>
                            <p class="button-height inline-label">
                                <label class="label">Active</label>
                                <?php echo $this->Form->input('active', array('id'=>'active', 'class' => 'select expandable-list validate[required] ','style'=>'width:105px;', 'options'=>array('y'=>'Active', 'n'=>'Inactive'), 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label" style="width:auto;">Select Modules to use for this Group</label>
                                <div style="height: 150px; overflow: auto; padding: 5px; border:1px solid #b2b2b2; border-radius: 5px;">
                                    <?php
                                    if(!empty($allModules)){
                                        $module_count = 0;
                                        foreach($allModules as $module){
                                            ?>
                                            <div><?php echo $this->Form->input("ModulesGroup.$module_count.module_id", array('type'=>'checkbox', 'div' => false, 'label' => false, 'class' => '', 'value'=>''.$module['Module']['id'].'')); ?><?php echo " &nbsp;&nbsp;".$module['Module']['name']; ?></div>
                                            <?php
                                            $module_count++;
                                        }
                                    }
                                    ?>
                                </div>
                            </p>

                            <p class="button-height inline-label">
                                <label for="save-btn" class="label">&nbsp;</label>
                                <button type="submit" class="button" id="save-btn">
                                    <span class="button-icon green-gradient"><span class="icon-download"></span></span>
                                    Save
                                </button>

                                <button type="button" class="button" id="cancel-btn">
                                    <span class="button-icon anthracite-gradient"><span class="icon-cross-round"></span></span>
                                    Cancel
                                </button>
                            </p>
                        </fieldset>
                        <?php echo $this->Form->end();?>
                        <input type="hidden" name="modules_count" id="modules_count_id" value="<?php echo count($allModules);?>"/>
                    </div>
                </div>

            </div>
        </div>
    </div>

</section>
<!-- End main content -->

<!-- Side tabs shortcuts -->
<?php echo $this->element('side_tabs_shortcuts'); ?>
<!-- Sidebar/drop-down menu -->
<?php echo $this->element('right_side_infos'); ?>

<input type="hidden" id="group-table-url" value="<?php echo $this->Html->url(array('controller' => 'Administration', 'action' => 'getGroups')); ?>" />
<input type="hidden" id="group-add-edit-url" value="<?php echo $this->Html->url(array('controller' => 'Administration', 'action' => 'add')); ?>" />
<input type="hidden" id="load-group-url" value="<?php echo $this->Html->url(array('controller' => 'Administration', 'action' => 'loadGroup')); ?>" />
<input type="hidden" id="group-delete-url" value="<?php echo $this->Html->url(array('controller' => 'Administration', 'action' => 'deleteGroups')); ?>" />

<?php
echo $this->Html->script('setup.js');
/** Template functions **/
echo $this->Html->script('developr.input.js');
echo $this->Html->script('developr.message.js');
echo $this->Html->script('developr.modal.js');
echo $this->Html->script('developr.navigable.js');
echo $this->Html->script('developr.notify.js');
echo $this->Html->script('developr.scroll.js');
echo $this->Html->script('developr.progress-slider.js');
echo $this->Html->script('developr.tooltip.js');
echo $this->Html->script('developr.confirm.js');
echo $this->Html->script('developr.agenda.js');
echo $this->Html->script('developr.tabs.js');

echo $this->Html->script('libs/tinycon.min.js');
echo $this->Html->script('custom-scripts/admin/groups.js');

// Charts library
// Load the AJAX API
//echo $this->Html->script('google/jsapi.js');
//echo $this->Html->script('custom-scripts/charts.js');
?>